<template>
    <div>
        <el-button type="danger" @click="previewURL()">URL Array</el-button>
        <el-button type="danger" @click="previewImgObject()">Img-Object Array</el-button>
    </div>
</template>

<!-- v-viewer使用参考地址：https://github.com/mirari/v-viewer -->
<script>
    import 'viewerjs/dist/viewer.css'
    import { api as viewerApi } from "v-viewer"

    export default {
        name: "imageview",
        data() {
            return {
                sourceImageURLs: [
                    'http://halo.lxyccc.top/44dsdsdsds4.jpg',
                    'http://halo.lxyccc.top/评价-星标1.png',
                    'http://halo.lxyccc.top/头像.jpg'
                ],
                sourceImageObjects: [
                    {
                        'src':'http://halo.lxyccc.top/评价-星标1.png',
                        'data-source':'http://halo.lxyccc.top/评价-星标1.png'
                    },
                    {
                        'src':'http://halo.lxyccc.top/44dsdsdsds4.jpg',
                        'data-source':'http://halo.lxyccc.top/44dsdsdsds4.jpg'
                    }
                ]
            }
        },
        methods: {
            previewURL () {
                // 如果使用`app.use`进行全局安装, 你就可以像这样直接调用`this.$viewerApi`
                const $viewer = viewerApi({
                    images: this.sourceImageURLs
                })
            },
            previewImgObject () {
                // 或者你可以单独引入api然后执行它
                const $viewer = viewerApi({
                    options: {
                        toolbar: true,
                        url: 'data-source',
                        initialViewIndex: 1
                    },
                    images: this.sourceImageObjects
                })
            }
        }
    }
</script>

<style scoped>

</style>
